package com.zit.java.interceptor;

import com.zit.java.controller.BaseController;
import org.springframework.web.servlet.HandlerInterceptor;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import java.io.IOException;

public class LoginInterceptor extends BaseController implements HandlerInterceptor {
    @Override
    public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws IOException {
          HttpSession httpSession = request.getSession();
          Object object = httpSession.getAttribute(SESSIONOBJ);
          if (object==null){
              //重定向
             response.sendRedirect("login/tologin");
              return false;
          }else {
              return true;
          }
    }
}
